/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.SinhalaSpellChecker;

import com.sun.star.lang.Locale;



/**
 *
 * @author S De Silva
 */
public class XSpellAlternatives_impl implements com.sun.star.linguistic2.XSpellAlternatives{

    String aWord;
    Locale aLanguage;
    String[] aAlt;           // list of alternatives, may be empty.
    short nType;          // type of failure

    /**
     * Class constructor to initialize the variables used in this class
     * @param aWord the input word by the user through OpenOffice
     * @param aLanguage the locale of the spell checker
     * @param nFaliureType the short value which indicates the type of faliure
     * @param aAlt string array containing the suggestions
     */
    public XSpellAlternatives_impl(String aWord, Locale aLanguage, short nFailureType, String[] aAlt )
    {
        this.aWord      = aWord;
        this.aLanguage  = aLanguage;
        this.aAlt       = aAlt;
        this.nType      = nFailureType;

        if (this.aWord == null)
            this.aWord = new String();
        if (this.aLanguage == null)
            this.aLanguage = new Locale();

        if (this.aAlt == null)
            this.aAlt = new String[]{};
    }

    /**
     * Return the word typed by the user
     * @return the word typed by the user
     */
    public String getWord() throws com.sun.star.uno.RuntimeException
    {
        return aWord;
    }
    /**
     * Return the locale used in the spell checker
     * @return the locale supoorted by the user
     */
    public Locale getLocale() throws com.sun.star.uno.RuntimeException
    {
        return aLanguage;
    }
    /**
     * Return the faliure type as a short value
     * @return the faliure as short value
     */
    public short getFailureType() throws com.sun.star.uno.RuntimeException
    {
        return nType;
    }

    /**
     * Return the number of alternatives as a short value
     * @return the number of alternative
     */
    public short getAlternativesCount() throws com.sun.star.uno.RuntimeException
    {
        return (short) aAlt.length;
    }

    /**
     * Return the alternatives for the given word as a string array
     * @return the string array containing alternatives
     */
    public String[] getAlternatives() throws com.sun.star.uno.RuntimeException
    {
        return aAlt;
    }

}
